#include "MsgUtils.h"
//创建消息队列
    int getMsgQueue(char *pathName,int processId)
    {
        key_t key = ftok(pathName,processId);
        if (key == -1)
        {
            perror("fork():");
            return -1;
        }
        int mqId = msgget(key,IPC_CREAT|0666);
        if (mqId == -1)
        {
            perror("msgget():");
            return -1;
        }
        return mqId;
    }
    //发送消息
    int sendMsg(int mqId,Message* msg,int msgSize)
    {
        int ret = msgsnd(mqId,msg,msgSize,0);
        if (ret == -1)
        {
            perror("send msg error");
            return -1;
        }
        return ret;
    }
    // 接收消息
    int recvMsg(int mqId,Message* msg,int msgSize)
    {
        printf("11111mqId:%d\n",mqId);
        int ret = msgrcv(mqId,msg,msgSize,0,0);
        printf("22222ret:%d\n" ,ret);

        if (ret == -1)
        {
            perror("recive msg error:");
            return -1;
        }
        printf("22222 \n");
        return ret;
    }